<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>友情链接列表</title>
<link rel="stylesheet" href="${base}/images/contentImage/main.css" />
<script type="text/javascript" src="${base}/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="${base}/js/lhgdialog/lhgdialog.min.js"></script>
<script type="text/javascript" src="${base}/js/My97DatePicker4_8/WdatePicker.js"></script>
<script>
function updateLink(id){
	 var url = "url:"+"${base}/link/admin/editLink.htm?linkId="+id;
     $.dialog({
		lock: true,
		title:"友情链接编辑",
		content: url,
		cancelVal: '取消',
		width:'400px',
		height:'360px',
	    cancel: function(){ //请求成功后处理函数。 
	    		$.dialog.tips('数据刷新中...',600,'loading.gif');
	    		refreshIframe();
		},
		button: [{name: '保存',callback:function(){this.content.updateLink();return false;}}]
	});
}

function showLink(id){
	var url = "url:"+"${base}/link/admin/showLink.htm?linkId="+id;
    $.dialog({
		lock: true,
		title:"友情链接查看",
		content: url,
		cancelVal: '关闭',
		width:'400px',
		height:'360px',
	    cancel: function(){ 
		}
	});
}

function getCheckBox(){	 
    var ids="";
    $("input[name='ids']:checked").each(function(){  
		ids += $(this).val()+",";
	});
    if (ids.length > 0) ids = ids.substring(0, ids.length-1);      
	return ids;
}

function delLink(id){
	if(!id){
		var ids = getCheckBox(); 
		if(!ids){
			$.dialog.alert("请选择至少一个多选框！");
			return;
		}
		$.dialog.confirm('是否确定删除?',function(){
			$.dialog.tips('友情链接删除中...',999999,'loading.gif');
			$.ajax({
 				type: 'POST',
 				dataType : "json",
 				data:{"linkIdStr":ids},
 				url:  "/link/admin/deleteLink.htm",
 				error: function () {//请求失败处理函数
 					$.dialog.alert('请求失败！'); 				
 				},
 				success:function(data){ //请求成功后处理函数。 
 					$.dialog.alert(data.result,function(){
 						refreshIframe();
 					});
 				}
 			});
		},function(){},this);

	}else{
		$.dialog.confirm('是否确定删除?',function(){
			$.dialog.tips('友情链接删除中...',999999,'loading.gif');
			$.ajax({
 				type: 'POST',
 				dataType : "json",
 				data:{"linkId":id },
 				url:  "/link/admin/deleteLink.htm",
 				error: function () {//请求失败处理函数
 					$.dialog.alert('请求失败！'); 				
 				},
 				success:function(data){ //请求成功后处理函数。 
 					$.dialog.alert(data.result,function(){
 						refreshIframe();
 					});
 					
 				}
 			});
		},function(){},this);

	}
}
function addLink(){
	var url = "url:"+"${base}/link/admin/addLink.htm";
    $.dialog({
		lock: true,
		title:"友情链接新增",
		content: url,
		cancelVal: '取消',
		width:'400px',
		height:'360px',
	    cancel: function(){ //请求成功后处理函数。 
	    		$.dialog.tips('数据刷新中...',600,'loading.gif');
	    		refreshIframe();
		},
		button: [{name: '保存',callback:function(){this.content.saveLink();return false;}}]
	});
}
function refreshIframe(){
	$("#tableForm").submit();
}
</script>
</head>

<body>
<form action="${base!}/link/admin/list.htm" method="post" id = "tableForm" >
	<div class="titbg02">
		<strong class="fl">内容列表</strong>
		<a  href="#" id="del_button" onclick="delLink()" class="fr"><img border="0" align="absmiddle" src="${base}/images/contentImage/delForCh.gif">&nbsp;删除</a>
		<a  href="#" id="add_button" onclick="addLink()" class="fr"><img border="0" align="absmiddle" src="${base}/images/contentImage/addForCh.gif">&nbsp;新增</a>
	</div>

	<div class="titb border_all"  style="width:98%;margin:5px auto">
		<div>
		链接名: <input type="text"  class="w80" name="linkName" value="${link.linkName!}" id="linkName"/>&nbsp;
		链接地址: <input type="text"  class="w80" name="linkUrl" value="${link.linkUrl!}" id="linkUrl"/>&nbsp;		
		&nbsp;&nbsp;<input type="submit" value="查询" />
		</div>
	</div>

	<table border="0" cellspacing="1" cellpadding="0" class="w100" style="border-top:1px solid #ccc;">
  		<tr class="trtit" align="center">
		    <td width="28" align="center" ><img src="${base}/images/contentImage/down.png"></td>
		    <td class="border_b_r" width="28" align="center"><input type="checkbox" onClick="chooseAll(this.checked)" /></td>
		    <td class="border_b_r" width="280">连接名</td>
		    <td class="border_b_r">链接地址</td>
		    <td class="border_b_r">链接图标</td>
		    <td class="border_b_r">链接类型</td>
		    <td class="border_t_b" width="120">操作</td>    
  		</tr>
	<#if pagination??> 
		<#if pagination.list??>
			<#list pagination.list as link>			
			<tr>
				<td align="center" class="rowIdx">&nbsp;</td>
	    		<td class="border_b_r" align="center"><input type="checkbox" name='ids' value='${link.linkId}'/></td>
				<td class="border_b_r">${link.linkName}</td>
			    <td class="border_b_r">${link.linkUrl}</td>
				<td class="border_b_r">${link.imageUrl}</td>
				<td class="border_b_r">
					<#if link.linkType==1>页面下方友情链接</#if>
					<#if link.linkType==2>QQ咨询链接</#if>
				</td>
				<td class="border_b_r">
					<a href="javascript:showLink(${link.linkId});">查看</a>
					&nbsp;|&nbsp;	
				    <a href="javascript:updateLink(${link.linkId});">修改</a>
				    &nbsp;|&nbsp;				    
				    <a href="javascript:delLink(${link.linkId});">删除</a>
				</td>
			</#list>
	    </#if>
	 </#if>
	</table>
	<#include "${base}/server/link/pagination.html"/>
</form>
</body>
</html>
